﻿using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Text;

namespace MyCode.Tools
{
    public class HttpContextHelper
    {
        private static IHttpContextAccessor uniqueInstance;
        private HttpContextHelper()
        {

        }
        /// <summary>
        /// 定义公有方法提供一个全局访问点,同时你也可以定义公有属性来提供全局访问点
        /// </summary>
        /// <returns></returns>
        public static IHttpContextAccessor GetInstance()
                                              {
            // 如果类的实例不存在则创建，否则直接返回
            if (uniqueInstance == null)
            {
                uniqueInstance = new HttpContextAccessor();
            }
            return uniqueInstance;
        }

    }
}
